package homework;

public class Person {
    private String name;
    private double lifeValue;

    public Person() {
    }

    public Person(String name, double lifeValue) {
        this.name = name;
        this.lifeValue = lifeValue;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getLifeValue() {
        return lifeValue;
    }

    public void setLifeValue(double lifeValue) {
        if (lifeValue<0){
            throw new NoLifeValueException("生命值不能为负数");
        }else {
            this.lifeValue = lifeValue;
        }
    }

    @Override
    public String toString() {
        return name + "的生命值为" + lifeValue;
    }
}
